import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/layout/index.vue'
Vue.use(Router)

// export const constantRoutes = [
//   {
//     path: '',
//     component: layout,
//     redirect: 'index',
//     alwaysShow:1,
//     hidden:0,
//     menuName:'首页',
//     children: [
//       {
//         path: 'index',
//         component: (resolve) => require(['@/views/index'], resolve),
//         name: '首页',
//         alwaysShow:1,
//         hidden:0,
//         menuName:'首页',
//         icon: 'el-icon-s-home',
//         meta: { title: '首页', icon: 'el-icon-s-home', noCache: true, affix: true }
//       }
//     ]
//   },
//   {
//     path: '*',
//     redirect: '/404',
//     component: (resolve) => require(['@/views/error/404'], resolve),
//     hidden: true
//   },
//   // {
//   //   path: '/oauth',
//   //   name: '权限管理',
//   //   component: layout,
//   //   children:[
//   //     {path:'/menu',name:'菜单管理',component: () => import('@/views/oauth/menu'),},
//   //     {path:'/user',name:'菜单管理',component: () => import('@/views/oauth/user'),},
//   //   ]
//   // },
//   // {
//   //   path: '/blog',
//   //   name: '博客管理',
//   //   component: layout,
//   //   children:[
//   //     {path:'/blog',name:'博客列表',component: () => import('@/views/blog'),}
//   //   ]
//   // },
//   {
//     path: '/login',
//     name: 'login',
//     component: () => import('@/views/login')
//   }
// ]
// 公共路由
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: (resolve) => require(['@/views/redirect'], resolve)
      }
    ]
  },
  {
    path: '/login',
    component: (resolve) => require(['@/views/login'], resolve),
    hidden: true
  },
  {
    path: '/404',
    component: (resolve) => require(['@/views/error/404'], resolve),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'index',
    alwaysShow:1,
    hidden:1,
    menuName:'首页',
    children: [
      {
        path: 'index',
        component: (resolve) => require(['@/views/index'], resolve),
        name: '首页',
        alwaysShow:1,
        hidden:0,
        menuName:'首页',
        icon: 'el-icon-menu',
        meta: { title: '首页', icon: 'el-icon-menu', noCache: true, affix: true }
      }
    ]
  },
]

const router =  new Router({
  // mode: 'history',  //去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})
  export default router